package org.webrx;

public class Op1Demo {
    public static void main(String[] args) {
        //2.5
        System.out.println(5/2.0);
        //2
        System.out.println(5/2);
        //1
        System.out.println(5%2);


        int my = 5;
        System.out.println(my++);//在变量后++ 先被使用，再加加运算。输出5 然后 my变为6
        System.out.println(++my);
        System.out.println(my--);
        System.out.println(my);

        int x = 3;
        int y = 5;
        int z = x++ + y--;
        System.out.println("x=" + x);//x=4
        System.out.println("y=" + y);//y=4
        System.out.println("z=" + z);//z=9

        //System.out.println("ok");
        //System.out.println(2 * 3 - 2);
        //
        //System.out.printf("%.1f",1.2424242424);
        //
        //System.out.println();
        //System.out.printf("年龄：%03d岁%n", 10);
        //System.out.println("年龄：" + 10 + "岁");

        //算术运算符 + - * /整商 %取余 ++ --
        int a = 10;
        int b = 15;

        int c = a + b;
        a++; //就本变量，自己的值加上1 相当于 a = a + 1;
        --b;
        --b;
        --b;
        System.out.printf("%d+%d=%d%n", a, b, c);
        System.out.printf("%d+%d=%d%n", a, b, a + b);

        int d = a - b;
        System.out.printf("%d-%d=%d%n", a, b, d);

        int j = a * b; //*
        System.out.printf("%d×%d=%d%n", a, b, j);

        int m = a / b;//求整商
        System.out.printf("%d÷%d=%d%n", a, b, m);

        int n = a % b;
        System.out.printf("%d%%%d=%d%n", a, b, n);


    }
}
